<%--
    Document   : index
    Created on : Oct 27, 2009, 11:25:07 PM
    Author     : Johnathon Tieman
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="jhu.profiteer.data.Commodity" %>
<%@ page import="jhu.profiteer.data.CommodityJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Commodity";
    String cssFile = "/profiteer-game/css/profiteer.css";
    String param = request.getParameter("commodityId");
    Commodity c = null;

    if((null != param) && (!param.isEmpty()))
    {
      CommodityJpaController jc = new CommodityJpaController();
      c = jc.findCommodity(Long.parseLong(param));
    }
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <form action="processCommodity" method="post">
                  <% if (null != c) { %><input type="hidden" name="commodityId" value="<%= c.getId() %>" /><% } %>
                  <table>
                    <tr>
                      <td>Name:</td>
                      <td><input type="text" name="name" <% if(null != c) { %> value="<%= c.getName() %>" <% } %>/></td>
                    </tr>
                    <tr>
                      <td>Description:</td>
                      <td><input type="text" name="description" <% if(null != c) { %> value="<%= c.getDescription() %>" <% } %>/></td>
                    </tr>
                  </table>
                  <input type="submit" name="submit" <% if(null == c) { %> value="Create" <% } else { %> value="Update" <% } %> />
                </form>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>